﻿using Coldairarrow.Business.Base_leasesystem_servicesign;
using Coldairarrow.Entity.Base_leasesystem_servicesign;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_servicesign
{
    /// <summary>
    /// 客户与服务商签约控制器
    /// </summary>
    [Route("/Base_leasesystem_servicesign/[controller]/[action]")]
    [OpenApiTag("客户与服务商签约控制器")]
    public class leasesystem_servicesignController : BaseApiController
    {
        #region DI

        public leasesystem_servicesignController(Ileasesystem_servicesignBusiness leasesystem_servicesignBus)
        {
            _leasesystem_servicesignBus = leasesystem_servicesignBus;
        }

        Ileasesystem_servicesignBusiness _leasesystem_servicesignBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<object> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_servicesignBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_servicesign> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_servicesignBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 根据MID 查询服务商信息及服务商开户行
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<object> GetService_BankByMID(IdInputDTO input)
        {
            return await _leasesystem_servicesignBus.GetService_BankByMID(input.id);
        }

        /// <summary>
        /// 连表查询所有数据，客户签约--客户表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public object GetAll(PageInput<ConditionDTO> input)
        {
            return _leasesystem_servicesignBus.GetAll(input);
        }

        
        
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_servicesign data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);
                data.FileAttId = IdHelper.GetId();
                await _leasesystem_servicesignBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_servicesignBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("servicesign.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_servicesignBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}